Permissions are the rules. Ownership is the right to change the rules. 👑
Understand ownership through the "Locker" concept:
chmod (Permissions).Key Takeaway: You can only change permissions (
chmod) if you are the Owner of the file.
Use ls -l to see who's in charge.
ls -l filename
# Output:
# -rw-r--r-- 1 kali developers 4096 Feb 11 10:00 filename
| Output Part | Meaning | Description |
|---|---|---|
kali |
User (Owner) | The person who owns the file. The "Bank Manager". |
developers |
Group | The group associated with the file. |
chown & chgrpâš ï¸ Warning: Changing ownership is a powerful action. You almost always need
sudo(Root privileges) to do this.
chown)sudo chown newuser filename
# The old owner loses control, 'newuser' is now the boss.
chgrp)sudo chgrp newgroup filename
# The file now belongs to the 'newgroup'.
The professional way to do it in one command.
sudo chown user:group filename
# Example:
sudo chown kali:root server.log
root make the file super powerful?A: No!
The root group is just a name. It does not grant magical powers to the file itself. It simply means that users in the root group have the group permissions (e.g., read/write) for that file.
root group do anything it wants?A: No.
Members of the root group can only do what the Owner has permitted for the Group. If the owner sets group permissions to "read-only" (r--), even the root group can only read (unless you are the actual root user, who bypasses everything 😉).
Want to know which clubs you belong to?
groups
# Output example:
# kali adm cdrom sudo dip plugdev users
sudo group allows you to use the sudo command.